package com.langll.mcp.service;

import com.langll.mcp.portfolio.service.IPortfolioProductService;
import lombok.RequiredArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.ai.tool.annotation.Tool;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@Service
@RequiredArgsConstructor
public class DateService {

    private static final Logger LOGGER = LoggerFactory.getLogger(DateService.class);

    public static class AddressRequest {
        private String address;

        public String getAddress() {
            return address;
        }

        public void setAddress(String address) {
            this.address = address;
        }
    }

    public static class DateResponse {
        private String result;

        public DateResponse(String result) {
            this.result = result;
        }

        public String getResult() {
            return result;
        }

        public void setResult(String result) {
            this.result = result;
        }
    }

    private final IPortfolioProductService iPortfolioProductService;

    @Tool(name = "getAddressDate", description = "获取指定地点的当前时间")
    public DateResponse getAddressDate(AddressRequest request) {
        String result = String.format("%s的当前时间是%s",
                request.getAddress(),
                LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
        LOGGER.info(result);
        long count = iPortfolioProductService.count();
        LOGGER.info(String.valueOf(count));
        return new DateResponse(result);
    }
}
